﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="JiuQianTS.aspx.cs" Inherits="Web.Pages.YongShui.JiuQianTS" Theme="Default" %>

<%@ Register Assembly="DevExpress.Web.v15.2, Version=15.2.9.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a" Namespace="DevExpress.Web" TagPrefix="dx" %>
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <script src="../../../../JS/AddEditCancel.js"></script>
    <script src="../../../JS/jquery-1.11.1.min.js"></script>
    <script type="text/javascript">
        //禁用Enter键表单自动提交
        document.onkeydown = function (event) {
            var target, code, tag;
            if (!event) {
                event = window.event; //针对ie浏览器
                target = event.srcElement;
                code = event.keyCode;
                if (code == 13) {
                    tag = target.tagName;
                    if (tag == "TEXTAREA") { return true; }
                    else { return false; }
                }
            }
            else {
                target = event.target; //针对遵循w3c标准的浏览器，如Firefox
                code = event.keyCode;
                if (code == 13) {
                    tag = target.tagName;
                    if (tag == "INPUT") { return false; }
                    else { return true; }
                }
            }
        };

        $(function () {
            
        })

        function selectedGuanlikChange()
        {
            gvList1.PerformCallback();
        }
        //打开子窗体
        function openWindow(type) {
            if (type ==1) {//旧欠汇总
                openCenter("/Pages/YongShui/5.ShouFeiGL/JiuQianTSHZ.aspx?", "600px", "670px");
            }
            else if (type == 2) {//增加托收明细
                //此时为进账单未到账,进一步判断银行接口是否上传
                if (hdCollection.Get('sczt') == "1")
                {
                    alert('已上传,不能增加或删除！请再生成一个新的进账单。');
                    return;
                }
                var sfbh = getKeyToArr()[0];
                openCenter("/Pages/YongShui/5.ShouFeiGL/JiuQianTSMX_ZJ.aspx?guanlikh=" + cmbconGuanlik.GetValue() + "&sfbh=" + sfbh, "900px", "450px");
            }
            else if (type == 3) {//生成新的进账单
                //判断是否可以生成
                ASPxCallback1.PerformCallback("createnew");                
            }
        }
        
        function search()
        {
            if (txtconYonghuh.GetText() == "")
            {
                return;
            }
            ASPxCallback1.PerformCallback("search");
        }

        function grid1focus()
        {
            var dzbz = getKeyToArr()[1];
            //var dzbz = gvList1.GetRowKey(gvList1.GetFocusedRowIndex());
            //hdCollection.Set("dzbz", dzbz);
            if (dzbz != "1") {
                btnCreateNew.SetEnabled(false);
                btnOpenAddDetail.SetEnabled(true);
            }
            else {
                btnCreateNew.SetEnabled(true);
                btnOpenAddDetail.SetEnabled(false);
            }
            if (dzbz == "0")
            {
                btnOpenAddDetail.SetEnabled(false);
                $(".aDel").hide();
            }
            gvList2.PerformCallback();
        }
        function grid1endcallback() {
                grid1focus();   
        }

        function grid2endcallback()
        {
            var dzbz = getKeyToArr()[1];
            if (dzbz == "1") {
                $(".aDel").hide();
            }
            else {
                $(".aDel").show();
            }
        }
        //删除托收凭证
        function delmx()
        {
            //上传标志
            var scbz = getKeyToArr()[2];
            //var scbz = hdCollection.Get("scbz");
            if (scbz == "1") {
                alert('已上传,不能增加或删除！请再生成一个新的进账单。');
                return false;
            }
            if (confirm('你确认取消当前的托收凭证吗？')) {
                ASPxCallback1.PerformCallback("delmx");
                LoadPanel.Show();
            }
        }

        function getKeyToArr()
        {
            return gvList1.GetRowKey(gvList1.GetFocusedRowIndex()).split(',');
        }
        
    </script>
    <script type="text/javascript">

        function ASPxCallback1Complete(rs) {
            var arr = rs.split('|');
            var type = arr[0];
            var state = arr[1];
            var specialIdentity = arr[2];
            var msg = arr[3].split('-');
            LoadPanel.Hide();
            if (msg[0] == 'True') {
                alert(msg[1]);
            }
            //debugger;
            hdCollection.Set("type", type);
            if (state == 'True') {
                if (type == "createnew") {
                    openCenter("/Pages/YongShui/5.ShouFeiGL/JiuQianTSMX_ZJ.aspx?guanlikh=" + cmbconGuanlik.GetValue(), "900px", "450px");
                }
                else if (type == "delmx") {
                    btnRunServer.onClick();
                }
                else if (type == "search") {
                    gvList2.SetFocusedRowIndex(arr[4]);
                    gvList2.MakeRowVisible(arr[4]);
                }
            }
            else {
            }
        }

        
</script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
        <div class="tabletitle1" align="center">
            旧欠托收
        </div>
        <asp:UpdatePanel ID="updatePanel1" runat="server">
            <ContentTemplate>
                <dx:ASPxHiddenField ID="ASPxHiddenField1" ClientInstanceName="hdCollection" runat="server"></dx:ASPxHiddenField>
        <dx:ASPxCallback ID="ASPxCallback1" ClientInstanceName="ASPxCallback1" runat="server" OnCallback="ASPxCallback1_Callback" ClientSideEvents-CallbackComplete="function(s,e){ASPxCallback1Complete(e.result);}"></dx:ASPxCallback>
        <dx:ASPxLoadingPanel ID="ASPxLoadingPanel1" ClientInstanceName="LoadPanel" runat="server"></dx:ASPxLoadingPanel>
                <dx:ASPxButton ID="btnRunServer" ClientInstanceName="btnRunServer" OnClick="btnRunServer_Click" ClientVisible="false" runat="server" Text="ASPxButton"></dx:ASPxButton>

            <div class="top" style="width: 98%;margin:auto;">
                <fieldset style="border: 1px solid  cornflowerblue;width:98%; margin:auto;">
                    <legend style="font-weight: bold">托收汇总</legend>
                    <table>
                        <tr>                            
                            <td>管理块：</td>
                            <td>
                                <dx:ASPxComboBox ID="cmbconGuanlik" ClientInstanceName="cmbconGuanlik" runat="server" ValueType="System.String" AutoPostBack="false"  Width="80px">
                                    <ClientSideEvents  SelectedIndexChanged="function(s,e){selectedGuanlikChange()}"/>
                                </dx:ASPxComboBox>
                            </td>
                            <td>
                                <dx:ASPxButton ID="btnCreateNew" ClientInstanceName="btnCreateNew" runat="server" Text="生成新的进账单" AutoPostBack="false" UseSubmitBehavior="false">
                                    <ClientSideEvents  Click="function(s,e){openWindow(3);}"/>
                                </dx:ASPxButton>
                            </td>
                            <td>
                                <dx:ASPxButton ID="btnOpenAddDetail" ClientInstanceName="btnOpenAddDetail" runat="server" Text="增加托收明细" AutoPostBack="false" UseSubmitBehavior="false">
                                    <ClientSideEvents  Click="function(s,e){openWindow(2);}"/>
                                </dx:ASPxButton>
                                <dx:ASPxHiddenField ID="hdCollection" runat="server"></dx:ASPxHiddenField>
                            </td>                            
                            <td>
                                <dx:ASPxButton ID="btnOpenGeranize" runat="server" Text="查看汇总" AutoPostBack="false" UseSubmitBehavior="false">
                                    <ClientSideEvents  Click="function(s,e){openWindow(1);}"/>
                                </dx:ASPxButton>
                            </td>
                        </tr>
                    </table>
                    <dx:ASPxGridView ID="gvList1" ClientInstanceName="gvList1" runat="server" AutoGenerateColumns="False" KeyFieldName="KEYCOLUMN" Theme="Aqua1" Width="80%" EnableCallBacks="true" OnCustomCallback="gvList1_CustomCallback"  OnHtmlRowPrepared="gvList1_HtmlRowPrepared" >
                                        <Columns>
                                            <dx:GridViewDataTextColumn FieldName="I_SHOUFEIBH" Caption="进帐单编号" Width="20%" >
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="N_ZONGJINE" Caption="总金额" Width="30%" PropertiesTextEdit-DisplayFormatString="0.00" >
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="I_ZONGBIS" Caption="总笔数" Width="20%"  >
                                            </dx:GridViewDataTextColumn>                                            
                                            <dx:GridViewDataTextColumn FieldName="D_HEZHANGRQ" Caption="重托日期" Width="30%" PropertiesTextEdit-DisplayFormatString="yyyy-MM-dd">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="I_DAOZHANGBZ" Caption="到账标志" Width="0px">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="I_SHANGCHUANBZ" Caption="上传标志"  Width="0px">
                                            </dx:GridViewDataTextColumn>
                                        </Columns>
                                        <Settings VerticalScrollableHeight="100" VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" />
                                        <SettingsBehavior ProcessFocusedRowChangedOnServer="false" SortMode="Custom" />
                                        <ClientSideEvents  FocusedRowChanged="function(s,e){grid1focus();}" EndCallback="function(s,e){grid1focus();}"  />
                                    </dx:ASPxGridView>
                </fieldset>
            </div>
            <div style="width: 98%; text-align:center;margin:auto;">
            <div style="height:1px"></div>
                <table>
                    <tr>
                        <td>
                            <dx:ASPxComboBox ID="cmbconGotoType" runat="server" ValueType="System.String">
                        <Items>
                            <dx:ListEditItem  Text="按用户号定位" Value="1"/>
                            <dx:ListEditItem  Text="按托收凭证号定位" Value="2"/>
                        </Items>
                    </dx:ASPxComboBox>
                        </td>
                        <td>
                            <dx:ASPxTextBox ID="txtconYonghuh" ClientInstanceName="txtconYonghuh"  runat="server" Width="100px">
                                 <ClientSideEvents KeyPress="function(s,e){if(event.keyCode == 13){search();}}" />
                            </dx:ASPxTextBox>
                        </td>
                        <td>
                            <dx:ASPxButton ID="btnConGoto" runat="server" Text="定位" UseSubmitBehavior="false"  AutoPostBack="false" ClientSideEvents-Click="function(s,e){search();}"></dx:ASPxButton>
                        </td>
                    </tr>
                </table>
                <div style="height:1px"></div>
                <dx:ASPxGridView ID="gvList2" ClientInstanceName="gvList2" runat="server" AutoGenerateColumns="False" KeyFieldName="I_HUIZONGBH" Theme="Aqua1" Width="100%" OnCustomCallback="gvList2_CustomCallback">
                                        <Columns>
                                            <dx:GridViewDataTextColumn FieldName="I_TUOSHOUPZH" Caption="托收号码" Width="80px">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_YONGHUH" Caption="用户号" Width="80px">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_YONGHUM" Caption="用户名" Width="250px">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="I_YM" Caption="水量月" Width="60px" CellStyle-HorizontalAlign="Center">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="N_JINE" Caption="金额" Width="80px" PropertiesTextEdit-DisplayFormatString="0.00">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_KAIHUHM" Caption="开户户名" Width="250px">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_KAIHUZH" Caption="银行账号" Width="150px">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn FieldName="S_KAIHUYH" Caption="开户银行" Width="150px">
                                            </dx:GridViewDataTextColumn>
                                            <dx:GridViewDataTextColumn Width="35px">
                                                <DataItemTemplate>
                                                    <a class="aDel" runat="server" id="aDel" href="#" onclick="delmx();">删除</a>
                                                </DataItemTemplate>
                                            </dx:GridViewDataTextColumn>
                                        </Columns>
                                        <Settings VerticalScrollableHeight="260" VerticalScrollBarMode="Auto" HorizontalScrollBarMode="Auto" />
                    <ClientSideEvents EndCallback="function(s,e){grid2endcallback();}" />
                                    </dx:ASPxGridView>                
            </div>
            </ContentTemplate>
        </asp:UpdatePanel>
    </form>
</body>
</html>


